package cn.ddiancan.xddcloud.ddccore.mulidatasource.context;

/**
 * datasource
 *
 * @author Amos
 * @since 2024-08-19
 */
public class DataSourceContextHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    /**
     * 获取指定数据库路由key
     *
     * @return
     */
    public static String getDataSourceKey() {
        return contextHolder.get();
    }

    public static void setDataSourceKey(String dataSourceKey) {
        contextHolder.set(dataSourceKey);
    }

    public static void clearDataSourceKey() {
        contextHolder.remove();
    }
}
